/* eslint-disable no-shadow */
export function count({ search }) {
  return RSocket.rr({
    route: 'tasks.count',
    args: { search },
  });
}

export function search({ search, pg }) {
  return RSocket.rs({
    route: 'tasks',
    args: { search, pg },
  });
}

/**
 * @func 统计可派车司机数量
 */
export function countSendCars(chauffeur) {
  return RSocket.rr({
    route: 'ccorders.get.chauffeur.count',
    args: { chauffeur },
  });
}

/**
 * @func 获取可派车司机信息
 */
export function searchSendCars(chauffeur, pg) {
  return RSocket.rs({
    route: 'ccorders.get.chauffeur',
    args: { chauffeur, pg },
  });
}

/**
 * @func 获取订单信息
 */
export function get(id) {
  return RSocket.rr({
    route: `ccorders.${id}`,
  });
}

/**
 * @func 调度员手工派车
 */
export function sendCar(data) {
  return RSocket.rr({
    route: 'ccorders.driver.dispatcher',
    data,
  });
}

/**
 * @func 日志流水分页条件查询
 * @param {}
 */
export function getLogs(search) {
  return RSocket.rs({
    route: 'logs',
    args: {
      search,
      pg: { page: 0, size: 100, sort: ['ts;desc'] },
    },
  });
}

/**
 * @func 获取任务流水日志
 */
export function getTaskLogs(id, username) {
  return RSocket.rr({
    route: `logs.${id}.get.time`,
    args: { username },
  });
}

/**
 * @func 人工干预任务状态
 */
export function updateTaskState(taskId) {
  return RSocket.rr({
    route: `tasks.manual.${taskId}.update.state`,
  });
}

/**
 * @func 获取任务信息
 */
export function getTaskInfo(id) {
  return RSocket.rr({
    route: `tasks.${id}`,
  });
}

/**
 * @func 取消司机
 */
export function cancelSendCar(data) {
  return RSocket.rr({
    route: 'tasks.cancel',
    data,
  });
}

/**
 * @func 通过日志流水获取任务时刻
 */
export function getLogTime(taskOrderId, username) {
  return RSocket.rr({
    route: `logs.${taskOrderId}.get.time`,
    args: { username },
  });
}

/**
 * @func  修改任务状态
 */
export function changeTaskState(taskId, args) {
  return RSocket.rr({
    route: `tasks.manual.${taskId}.update.state`,
    args,
  });
}

/**
 * @func  修改任务
 */
export function update(data) {
  return RSocket.rr({
    route: 'tasks.update',
    data,
  });
}

/**
 * @description 获取公司列表
 * @param {*} args 参数
 * @returns array
 */
export function company(args) {
  return RSocket.rs({
    route: 'companys',
    args: {
      search: {
        ...args,
      },
      pg: {
        page: 0,
        size: 999,
        sort: [],
      },
    },
  });
}
